package com.pyue.eam.regi.module.message.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.pyue.eam.app.api.entity.AppBaseEntity;
import com.pyue.eam.regi.module.message.enums.MsgTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * app角色表
 *
 * @author aeizzz
 * @date 2022-12-07 09:52:03
 */
@Data
@TableName("app_role")
@Schema(description = "消息通知")
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class AppMsg extends AppBaseEntity {

    /**
     * 消息id
     */
    private String id;

    /**
     * 消息头像
     */
    private String avatar;

    /**
     * 页面路径
     */
    private String pageUrl;

    /**
     * 业务id
     */
    private String bizId;

    /**
     * 标题
     */
    private String title;

    /**
     * 内容
     */
    private String content;


    public static AppMsg ofByEnum(MsgTypeEnum msgTypeEnum) {
        AppMsg build = AppMsg.builder()
                .title(msgTypeEnum.getMsgTitle())
                .avatar(msgTypeEnum.getAvatar())
                .pageUrl(msgTypeEnum.getPageUrl())
                .build();
        build.setCreateTime(LocalDateTime.now());

        return build;
    }

}
